package com.hinnotek.warehouse.api

import androidx.lifecycle.LiveData
import com.lee.common.bean.LoginBean
import com.hinnotek.warehouse.bean.*
import com.lee.common.di.BASE_URL
import com.lee.common.network.ApiFactory
import com.lee.common.network.WarehouseResponse
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.POST


interface WarehouseApi {

    companion object {
        fun get(): WarehouseApi {
            return ApiFactory.create(
                BASE_URL,
                true
            ) { code, msg, obj ->
                WarehouseResponse(obj, code, msg)
            }
        }
    }

    /*登录*/
    @FormUrlEncoded
    @POST("app/manage/appLogin")
    fun appLogin(
        @Field("userName") username: String,
        @Field("password") password: String
    ): LiveData<WarehouseResponse<LoginBean>>

    /*修改密码*/
    @FormUrlEncoded
    @POST("app/manage/updatePassword")
    fun changePass(
        @Field("userId") userId: Int,
        @Field("oldPassword") oldPassword: String,
        @Field("newPassword") newPassword: String
    ): LiveData<WarehouseResponse<LoginBean>>

    /**
     * 盘库
     */
    @FormUrlEncoded
    @POST("app/inventoryWarehouse/getSysWarehouseListByUserId")
    fun getSysWarehouseListByUserId(@Field("manageUserId") manageUserId: Int): LiveData<WarehouseResponse<MutableList<WareHouseInfoBean>>>

    @FormUrlEncoded
    @POST("app/inventoryWarehouse/getSysWarehouseDetailPageById")
    fun getSysWarehouseDetailPageById(
        @Field("wareId") wareId: Int,
        @Field("pageNo") pageNo: Int,
        @Field("pageSize") pageSize: Int,
    ): LiveData<WarehouseResponse<MutableList<WareHouseDetailBean>>>

    @FormUrlEncoded
    @POST("app/inventoryWarehouse/getWarehouseNumDetail")
    fun getWarehouseNumDetail(
        @Field("wareId") wareId: Int
    ): LiveData<WarehouseResponse<MutableList<MachineDetailBean>>>

    /**
     * 台账 入库 出库  借用  报损
     *  applyType（申请单类别：01-入库单；02-出库单；03-借用单；04-报损单）
     *  goodsType（货物类别：01-成品；02-半成品；03-原材料）
     *  approvalUserId（审批人用户id，当前登录用户id）
     */
    @POST("app/accountSummary/getWarehourseApplyFormPage")
    fun getWarehourseApplyFormPage(
        @Body body: RequestBody
    ): LiveData<WarehouseResponse<MutableList<MachineAccountBean>>>

    @FormUrlEncoded
    @POST("app/warehouseIn/getWarehourseInApplyFormDetail")
    fun getWarehourseInApplyFormDetail(
        @Field("applyId") applyId: Int
    ): LiveData<WarehouseResponse<MutableList<MachineAccountBean>>>

    @FormUrlEncoded
    @POST("app/accountSummary/getWarehourseApplyFormDeviceListByApplyId")
    fun getWarehourseApplyFormDeviceListByApplyId(
        @Field("applyId") applyId: Int
    ): LiveData<WarehouseResponse<MutableList<MachineListBean>>>


    @FormUrlEncoded
    @POST("app/accountSummary/getWarehourseApplyFormDetailListByApplyDeviceId")
    fun getWarehourseApplyFormDetailListByApplyDeviceId(
        @Field("applyDeviceId") applyDeviceId: Int
    ): LiveData<WarehouseResponse<MutableList<MachineDetailBean>>>


    @POST("app/warehourseApplyForm/addWarehourseApplyForm")
    fun addWarehourseApplyForm(
        @Body body: RequestBody
    ): LiveData<WarehouseResponse<MachineAccountBean>>

    //获取抄送人列表
    @POST("app/warehourseApplyForm/getSendUserList")
    fun getSendUserList(): LiveData<WarehouseResponse<MutableList<SpinnerUser>>>

    //获取审批人列表
    @POST("app/warehourseApplyForm/getApprovalUserList")
    fun getApprovalUserList(): LiveData<WarehouseResponse<MutableList<SpinnerUser>>>

    //获取料号列表
    @FormUrlEncoded
    @POST("app/warehourseApplyForm/getMaterielNumList")
    fun getMaterielNumList(@Field("wareId") wareId: Int): LiveData<WarehouseResponse<MutableList<WarehourseApplyFormDevicesRe>>>

    /**
     * 供应商信息
     *String deviceName（名称）
     *String deviceModel（型号）
     *String inputOutput（出入库状态，传00，初始状态）查出来的是所有未入库的设备。
     *Integer pageNo
     *Integer pageSize
     */
    @POST("app/warehouseIn/getDeviceAccountPage")
    fun getDeviceAccountPage(
        @Body body: RequestBody
    ): LiveData<WarehouseResponse<MutableList<WareHouseDetailBean>>>

    /**
     * 加入库扫描或手动输入
     */
    @POST("app/warehourseApplyForm/addInWarehourseApplyFormDeviceDetail")
    fun addInWarehourseApplyFormDeviceDetail(
        @Body body: RequestBody
    ): LiveData<WarehouseResponse<MachineAccountBean>>

    /**
     * 扫描设备详情    
     */
    @FormUrlEncoded
    @POST("app/deciceAccountUse/getDeviceAccountByProductNum")
    fun getDeviceAccountByProductNum(
        @Field("productNum") productNum: String
    ): LiveData<WarehouseResponse<DeviceInfoBean>>


    /**
     * 出库扫描或手动输入
     */
    @POST("app/warehourseApplyForm/addOutWarehourseApplyFormDeviceDetail")
    fun addOutWarehourseApplyFormDeviceDetail(
        @Body body: RequestBody
    ): LiveData<WarehouseResponse<MachineAccountBean>>


    /**
     * 添加借用扫描或手动输入入
     */
    @POST("app/warehourseApplyForm/addBorrowWarehourseApplyFormDeviceDetail")
    fun addBorrowWarehourseApplyFormDeviceDetail(
        @Body body: RequestBody
    ): LiveData<WarehouseResponse<MachineAccountBean>>


    /**
     * 添加报损扫描或手动输入
     */
    @POST("app/warehourseApplyForm/addFrmlossWarehourseApplyFormDeviceDetail")
    fun addFrmlossWarehourseApplyFormDeviceDetail(
        @Body body: RequestBody
    ): LiveData<WarehouseResponse<MachineAccountBean>>

    /**
     * 设备使用情况
     */
    @POST("app/deciceAccountUse/getDeviceAccountUsePage")
    fun getDeviceAccountUsePage(
        @Body body: RequestBody
    ): LiveData<WarehouseResponse<MutableList<DeviceInfoBean>>>

    /**
     * 审批申请
     */
    @POST("app/warehourseApplyForm/approvalWarehourseApplyForm")
    fun approvalWarehourseApplyForm(
        @Body body: RequestBody
    ): LiveData<WarehouseResponse<DeviceInfoBean>>

    /**
     * 仓库管理员扫描是否完成
     */
    @FormUrlEncoded
    @POST("app/warehourseApplyForm/completeWarehourseApplyForm")
    fun completeWarehourseApplyForm(
        @Field("applyId") applyId: Int
    ): LiveData<WarehouseResponse<DeviceInfoBean>>

    /**
     * 仓库管理员扫描是否完成
     */
    @FormUrlEncoded
    @POST("app/warehourseApplyForm/clickCompleteWarehouseApplyForm")
    fun clickCompleteWarehouseApplyForm(
        @Field("applyId") applyId: Int
    ): LiveData<WarehouseResponse<DeviceInfoBean>>

}